/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author HOME
 */
@Entity
@Table(name = "ERROR_REPORTS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ErrorReports.findAll", query = "SELECT e FROM ErrorReports e"),
    @NamedQuery(name = "ErrorReports.findByErrorReportId", query = "SELECT e FROM ErrorReports e WHERE e.errorReportId = :errorReportId"),
    @NamedQuery(name = "ErrorReports.findByErrorReportText", query = "SELECT e FROM ErrorReports e WHERE e.errorReportText = :errorReportText"),
    @NamedQuery(name = "ErrorReports.findByRaiseTime", query = "SELECT e FROM ErrorReports e WHERE e.raiseTime = :raiseTime")})
public class ErrorReports implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    //@Basic(optional = false)
    //@NotNull
    @Column(name = "ERROR_REPORT_ID")
    private BigDecimal errorReportId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1024)
    @Column(name = "ERROR_REPORT_TEXT")
    private String errorReportText;
    @Basic(optional = false)
    @NotNull
    @Column(name = "RAISE_TIME")
    @Temporal(TemporalType.TIMESTAMP)
    private Date raiseTime;
    @JoinColumn(name = "TEMPLATE_ID", referencedColumnName = "TEMPLATE_ID")
    @ManyToOne
    private Templates templateId;

    public ErrorReports() {
    }

    public ErrorReports(BigDecimal errorReportId) {
        this.errorReportId = errorReportId;
    }

    public ErrorReports(BigDecimal errorReportId, String errorReportText, Date raiseTime) {
        this.errorReportId = errorReportId;
        this.errorReportText = errorReportText;
        this.raiseTime = raiseTime;
    }

    public BigDecimal getErrorReportId() {
        return errorReportId;
    }

    public void setErrorReportId(BigDecimal errorReportId) {
        this.errorReportId = errorReportId;
    }

    public String getErrorReportText() {
        return errorReportText;
    }

    public void setErrorReportText(String errorReportText) {
        this.errorReportText = errorReportText;
    }

    public Date getRaiseTime() {
        return raiseTime;
    }

    public void setRaiseTime(Date raiseTime) {
        this.raiseTime = raiseTime;
    }

    public Templates getTemplateId() {
        return templateId;
    }

    public void setTemplateId(Templates templateId) {
        this.templateId = templateId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (errorReportId != null ? errorReportId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ErrorReports)) {
            return false;
        }
        ErrorReports other = (ErrorReports) object;
        if ((this.errorReportId == null && other.errorReportId != null) || (this.errorReportId != null && !this.errorReportId.equals(other.errorReportId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return errorReportId +":"+ templateId.toString();
    }
    
}
